<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="model.*" %>
<%@page import="control.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri = "http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
 <%
 pageContext.setAttribute("carrinho", Dados.carrinho);
 %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Biblioteca CultBook</title>
<link href="styles/default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<%@ include file="templates/topo.jsp" %>

<table width=70%>
<tr>
<td><b>Livro</b></td><td><b>Quantidade</b></td><td style="text-align:right"><b>Valor</b></td><td style="text-align:right"><b>Remover</b></td>
</tr>

<c:forEach var="Itens" items="${carrinho}">
	<tr>
	<td>
	<a href="livros/livro.jsp?i=${Itens.livro.isbn}">${Itens.livro.titulo}</a>
	</td>
	
	<td>${Itens.quantidade}</td>
	
	<td style="text-align:right"><fmt:formatNumber value="${Itens.livro.preco}" type="currency"/></td>
	
	<td style="text-align:right">
	<html:errors/>
	<html:form action="/addCarrinho">
	<html:hidden property="isbn" value="${Itens.livro.isbn}" />
	<html:hidden property="quantidade" value="0" />
	<html:submit value="x"/>
	</html:form>
	</td>
		
	</tr>
	<c:set var="total" value="${total+(Itens.quantidade*Itens.livro.preco)}" />
</c:forEach>

<tr>
<td colspan=3 style="text-align:right; font-size:18px"><b><fmt:formatNumber value="${total}" type="currency"/></b></td>
<td></td>
</tr>

</table>



	<html:errors/>
<html:form action="/finalizarPedido">
<html:hidden property="codigo"/>
	<html:hidden property="itens" />
<html:submit value="Fechar Pedido"/>
</html:form>



<%@ include file="templates/rodape.jsp" %>
</body>
</html>
